﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using System.Data.Linq;
using System.Data;
using System.Data.SqlClient;
namespace BAL
{
   public class BAL_PhieuThu
    {
       
        public QuanLyPhongTroDBDataContext dbs=new QuanLyPhongTroDBDataContext();
        public BAL_PhieuThu()
        {
            
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
                if (dbs != null)
                {
                    dbs.Dispose();
                    dbs = null;
                }
        }
       public List<PhieuThu> LayPhieuThu()
       {
           return dbs.PhieuThus.ToList();
       }
       public List<PhieuThu> TKPT_Thang(int thang)
       {

           return dbs.PhieuThus.ToList();
       }
       public void ThemPhieuThu(string maPhieuThu, string maHoaDon, string soTien, DateTime dt)
       {
           PhieuThu _phieuThu = new PhieuThu()
           {
               MaPhieuThu = maPhieuThu,
               MaHoaDon = maHoaDon,
               SoTien = int.Parse(soTien),
               NgayThu = dt
           };
           dbs.PhieuThus.InsertOnSubmit(_phieuThu);
           dbs.SubmitChanges();
   
       }
       public void XoaPhieuThu(string maPhieuThu)
       {
           PhieuThu _phieuThu = dbs.PhieuThus.Single(pt => pt.MaPhieuThu == maPhieuThu);
           dbs.PhieuThus.DeleteOnSubmit(_phieuThu);
           dbs.SubmitChanges();
       }
       public  void SuaPhieuThu(string maPhieuThu, string maHoaDon, string soTien, DateTime dt)
       {
           PhieuThu _phieuThu = dbs.PhieuThus.Single(pt => pt.MaPhieuThu == maPhieuThu);
           _phieuThu.MaHoaDon = maHoaDon;
           _phieuThu.SoTien = int.Parse(soTien);
           _phieuThu.NgayThu = dt;
           dbs.SubmitChanges();
       }
    }
}
